class TooLongException(Exception):
    def __init__(self,Errorinfo):
        super().__init__(self)
        self.errorinfo = Errorinfo

    def __str__(self):
        return self.errorinfo

try:
    name = input('请输入你的姓名：')
    len_name = len(name)
    if len_name <= 4:
        print(name)
    else:
        raise TooLongException(f'捕捉到异常了，异常信息：姓名长度为{len_name}，超过了长度')
except TooLongException as tle:
    print(tle)


